/* Copyright (c) 2011 by Mani Brundha Kattamuri, Haritha Subramanyam
 *
 * Project Info:  http://code.google.com/p/andriod-travelapp-csc780/wiki/Design
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
 * USA.
 */
package com.example.TravelApp.search.advanced;

import java.util.ArrayList;
import java.util.List;
import org.json.JSONObject;
import com.example.TravelApp.R;
import com.example.TravelApp.constants.MapConstants;
import com.example.TravelApp.search.common.PlaceObject;
import com.example.TravelApp.search.common.helper.PlacesDirectionHelper;
import com.example.TravelApp.search.common.helper.JSONParseHelper;

import android.os.Bundle;
import android.os.Parcelable;
import android.content.Intent;
import android.view.View;
import android.app.ListActivity;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

/**
 * This activity is called when the user wishes to view his previously saved
 * list. The list is received through an intent and AdvancedEachSubOptionDetail
 * Activity is called when user wants to continue with the list
 * 
 * @author Haritha Subramanyam, Mani Brundha
 * 
 */
public class SavedOptionActivity extends ListActivity {

	ArrayList<PlaceObject> recievedList = null;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// Users choices are received via content from Advanced activity
		Intent myIntent = getIntent();
		recievedList = myIntent.getParcelableArrayListExtra("placesList");

		// TO prevent Null Pointers; proceeds only if the list is not empty
		if ( recievedList != null&&recievedList.isEmpty() != true) {
			setContentView(R.layout.saved_option_layout);

		} else {
			// If no is data available displays proper message on the screen
			setContentView(R.layout.no_results);
		}

	}

	public void onClick(View v) {
		Intent intent = new Intent(getBaseContext(),
				AdvancedTabOptionDetailsActivity.class)
				.putParcelableArrayListExtra("placesList",
						(ArrayList<? extends Parcelable>) recievedList);
		startActivityForResult(intent, 0);
	}
}
